package com.example.anotheractivity;

import androidx.appcompat.app.AppCompatActivity;

import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.RemoteViews;
import android.widget.Toast;

import java.util.Date;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        RemoteViews views = new RemoteViews(getPackageName(), R.layout.layout_simulated_notification);
        views.setImageViewResource(R.id.imageView, R.drawable.ic_launcher_background);
        views.setTextColor(R.id.textView, Color.RED);
        views.setTextViewText(R.id.textView, "my progress:" + getPackageName());
        int requestId = (int) new Date().getTime();
        Intent intentActivity = new Intent();
        intentActivity.setComponent(new ComponentName("com.example.animationlearn",
                "com.example.animationlearn.NotificationActivity"));
        PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, requestId,
                intentActivity, PendingIntent.FLAG_UPDATE_CURRENT);
        views.setOnClickPendingIntent(R.id.textView, pendingIntent);
        Intent intent = new Intent("com.ssy.myintnent.action");
        intent.putExtra("com.ssy.myintnent.remoteview", views);
        //  View view = remoteViews.apply(NotificationActivity.this,li_1);
//        intent.setComponent(new ComponentName("com.example.animationlearn",
//                "com.example.animationlearn.NotificationActivity"));
        sendBroadcast(intent);
        Toast.makeText(this, "--", Toast.LENGTH_SHORT).show();
    }
}
